package com.asia5b.a5mall.home.activity

import androidx.lifecycle.Observer
import com.alibaba.android.arouter.facade.annotation.Route
import com.asia5b.a5bmall.resource.ActCons
import com.asia5b.a5bmall.same.dialog.UpdateDialog
import com.asia5b.a5mall.home.databinding.ActivityAboutBinding
import com.asia5b.a5mall.middleware.base.SimpleActivity
import com.asia5b.a5mall.middleware.logic.viewmodel.welcome.AboutVM
import com.asia5b.a5mall.middleware.utils.AppUtil
import kotlinx.android.synthetic.main.activity_about.*

/**
 * Created by zhangyuncai on 2019/12/21.
 * @Note   关于页面
 */
@Route(path = ActCons.AboutActivity)
class AboutActivity : SimpleActivity<AboutVM, ActivityAboutBinding>() {
    override var sIsDark = true
    override val viewModelClazz: Class<AboutVM>
        get() = AboutVM::class.java

    override fun getDataBinding(): ActivityAboutBinding {
        return ActivityAboutBinding.inflate(layoutInflater)
    }

    override fun initView() {
        mViewModel.createBitmap()

        about_version_tv.text = "V ${AppUtil.getVersionName()}"
    }

    override fun initEvent() {
    }

    override fun startObserver() {
        mViewModel.bitmapLiveData.observe(this, Observer {
            about_ercode_iv.setImageBitmap(it)
        })
        mViewModel.updateModelLiveData.observe(this, Observer { updateModel ->
            UpdateDialog.update(mActivity, updateModel)
        })
    }

    override fun initData() {
        checkUpdate()
    }

    private fun checkUpdate() {
        mViewModel.checkUpdate()

    }

}